package com.autumn.zero.authorization.repositorys.users;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import com.autumn.domain.repositories.IDefaultEntityRepository;
import com.autumn.zero.authorization.entitys.users.UserPermission;

/**
 * 用户授权仓储
 * 
 * @author 杨昌国 2018-11-29 21:07:33
 */
@Repository
public interface IUserPermissionRepository extends IDefaultEntityRepository<UserPermission> {

	/**
	 * 根据用户与资源类型删除权限
	 * 
	 * @param userId
	 *            用户id
	 * @param resourcesType
	 *            资源类型
	 * @return
	 */
	@Delete("DELETE p FROM sys_user_permission AS p INNER JOIN sys_res_module as m on p.resources_id = m.id WHERE p.user_id = #{userId} and m.resources_type = #{resourcesType}")
	int deleteByUserAndResourcesType(@Param("userId") long userId, @Param("resourcesType") int resourcesType);

}
